home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / vbasic / subvbx.exe / SUBVBCTL.CPP < prev    next >
C/C++ Source or Header  |  1993-08-25  |  4KB  |  121 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // subvbctl.cpp : implementation of the CVBClone class and CMyGrid class
  3. //                                                                                              
  4.  
  5. #include "stdafx.h"
  6. #include "subvbctl.h"  
  7.  
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CVBClone
  10. typedef CVBControl* __based((__segment)_self)* FAR* CVBHandle;  
  11.  
  12. //***********************************************************
  13. //
  14. //  CVBClone :: SubclassVBControl()
  15. //
  16. //  Purpose:  Copies data from an existing CVBControl class
  17. //            into this class.  It also detaches the old
  18. //            class and attaches this one.
  19. //                                                         
  20. //  Parameters:  CWnd* pParent     parent window of the control
  21. //               UINT  idChild     child window ID of control
  22. //               BOOL  bEmbedded   Inicates if contol is embedded
  23. //                                 in an object that will be 
  24. //                                 cleaned up or if this object
  25. //                                 should be deleted when the 
  26. //                                 control is deleted 
  27. //
  28. //  Return: None
  29. //
  30. //  Comments:
  31. //
  32. //  History:    Date       Author              Comment
  33. //              5/13/93    Brian Scott         Created
  34. //                         with help from John Seghers
  35. //
  36. //*************************************************************
  37.  
  38. void CVBClone::SubclassVBControl(CWnd* pParent, UINT idChild, BOOL bEmbedded)
  39. {
  40.     ASSERT(pParent != NULL);
  41.     ASSERT(idChild != 0 && idChild != -1);
  42.     
  43.     //
  44.     // Get the existing CVBControl.  Cast it to this class type
  45.     // so that we will have access to the protected data
  46.     //
  47.     CVBClone* pControl = (CVBClone*)pParent->GetDlgItem(idChild);
  48.     ASSERT(pControl->IsKindOf(RUNTIME_CLASS(CVBControl)));
  49.     
  50.     // Copy over all of the appropriate data
  51.     m_pModel = pControl->m_pModel;
  52.  
  53.     m_bRecreating = pControl->m_bRecreating;
  54.     m_bInPostNcDestroy = pControl->m_bInPostNcDestroy;
  55.     m_bLoading = pControl->m_bLoading;
  56.     m_nCursorID = pControl->m_nCursorID;
  57.     
  58.     m_nInitialStack = pControl->m_nInitialStack;
  59.     m_nRecursionLevel = pControl->m_nRecursionLevel;
  60.     m_bStackFault = pControl->m_bStackFault;
  61.     m_nFaultRecurse = pControl->m_nFaultRecurse;
  62.  
  63.     m_hbrBkgnd = pControl->m_hbrBkgnd;
  64.     m_hFontCreated = pControl->m_hFontCreated;
  65.     m_hcurMouse = pControl->m_hcurMouse;
  66.     m_hCtl = pControl->m_hCtl;
  67.     m_clrBkgnd = pControl->m_clrBkgnd;
  68.     m_clrFore = pControl->m_clrFore;
  69.     m_rectCreate = pControl->m_rectCreate;
  70.     m_strTag = pControl->m_strTag;
  71.  
  72.     m_bAutoDelete = !bEmbedded;
  73.  
  74.     // Clear data in the old CVBControl that would cause problems   
  75.     pControl->m_pModel = NULL;
  76.     pControl->m_hCtl   = NULL;
  77.     CVBHandle hpControl = (CVBHandle) m_hCtl;
  78.     **hpControl = this;
  79.     
  80.     pControl->m_hFontCreated=NULL;
  81.     pControl->m_hbrBkgnd=NULL;
  82.     pControl->m_hcurMouse=NULL;
  83.  
  84.     // Transfer hWnd
  85.     Attach(pControl->Detach());
  86.     
  87.     // Delete old object if necessary
  88.     if (pControl->m_bAutoDelete)
  89.         delete pControl;        
  90. }
  91.  
  92.  
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95. // CMyGrid
  96.  
  97. BEGIN_MESSAGE_MAP(CMyGrid, CVBClone)
  98.     //{{AFX_MSG_MAP(CMyGrid)
  99.     ON_WM_GETDLGCODE()
  100.     //}}AFX_MSG_MAP
  101. END_MESSAGE_MAP()  
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CMyCircle construction/destruction      
  105.  
  106. CMyGrid::CMyGrid() 
  107. {
  108.     // TODO: add construction code here
  109.  
  110. CMyGrid::~CMyGrid() 
  111. {
  112.     // TODO: add destruction code here
  113. }
  114.  
  115.  
  116. UINT CMyGrid::OnGetDlgCode()
  117. {       
  118.     return (CVBClone::OnGetDlgCode() | DLGC_WANTARROWS);
  119. }
  120.